library(foreign)
corr <- read.dta("Dropbox/PartyDuration/Data/corr.dta")
library(corrplot)
data<-subset(corr, select=rparty_lorg:predate )
plot<-cor(data, use="pairwise" ) [1:6,1:6]
colnames(plot) <- c("Local Org. Acitivity", "Local Org. Extensiveness", "Ties to Social Orgs", "Party Personalization", "Collective Nomination", "Party Predates Regime")
rownames(plot) <- c("Local Org. Acitivity", "Local Org. Extensiveness", "Ties to Social Orgs", "Party Personalization", "Collective Nomination", "Party Predates Regime")
plot1<-cor.mtest(data, use="pairwise", conf.level = .95)
p.mat <- cor.mtest(plot)$p
corrplot(plot, method="circle")
corrplot(plot, p.mat = plot1$p, insig = "label_sig",
         sig.level = c(.001, .01, .05), pch.cex = .9, pch.col = "white")

corrplot(plot, type = "upper", order = "hclust", 
         p.mat = p.mat, sig.level = 0.05, insig = "blank")

corrplot(plot,  insig = "label_sig", pch.col = "white",
         pch = "p<.05", pch.cex = .5, order = "hclust", type="upper")


corrplot(plot, method = "color",
         type = "upper", order = "hclust", number.cex = .7,
         addCoef.col = "black", # Add coefficient of correlation
         tl.col = "black", tl.srt = 90, # Text label color and rotation
         # Combine with significance
         p.mat = p.mat, sig.level = 0.1, insig = "n") 
         # hide correlation coefficient on the principal diagonal
        # diag = FALSE)